﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodWorx.CMS.Plugins;
using MethodWorx.Core.Serialization;
using System.Xml.Serialization;

namespace MethodWorx.CMS.Content
{
    [Serializable]
    public class PageProperty : ISerializationTypeDiscovery
    {
        [NonSerialized]
        private ICustomPropertyDetails value;

        public string Name
        {
            get;
            set;
        }

        [XmlIgnore]
        public ICustomPropertyDetails Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        public object ValueForSerialization
        {
            get { return this.Value; }
            set { this.Value = (ICustomPropertyDetails)value; }
        }

        public IEnumerable<Type> GetTypesForSerializer()
        {
            yield return this.GetType();
            if (this.ValueForSerialization != null)
                yield return this.ValueForSerialization.GetType();
        }
    }
}
